package ecs

import (
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	ecs20140526 "github.com/alibabacloud-go/ecs-20140526/v7/client"

	"aliyun-sdk/aliyun/credential"
)

// CreateClient 创建一个阿里云ECS客户端实例
// 参数:
//   - accessKeyid: 阿里云访问密钥ID
//   - accessKeySecret: 阿里云访问密钥
//   - endpoint: 阿里云ECS服务的访问端点
//
// 返回值:
//   - result: 返回一个ECS客户端实例指针
//   - err: 如果创建失败，返回错误信息
func CreateClient(accessKeyid, accessKeySecret, endpoint string) (result *ecs20140526.Client, err error) {
	c, err := credential.CreateCredentials(accessKeyid, accessKeySecret)
	if err != nil {
		return nil, err
	}
	config := &openapi.Config{
		Credential: c,
		Endpoint:   &endpoint,
	}
	r, err := ecs20140526.NewClient(config)
	if err != nil {
		return nil, err
	}
	return r, nil
}
